//
//  BankView.m
//  GoldOperationClient
//
//  Created by yaxue wang on 16/8/16.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "BankView.h"

@implementation BankView

-(instancetype)initWithFrame:(CGRect)frame witnOriginY:(float)originY withTitle:(NSString*)title{
    self = [super initWithFrame:frame];
    if (self) {
        [self bk_whenTapped:^{
            self.hidden=YES;
        }];
        self.originY=originY;
        self.backgroundColor=[[UIColor blackColor] colorWithAlphaComponent:0.4];
        
        self.whiteView=[[UIView alloc]initWithFrame:CGRectMake(0, self.bounds.size.height, WindowWidth, 0)];
        self.whiteView.backgroundColor=[UIColor whiteColor];
        [self addSubview: self.whiteView];
        self.hidden=YES;
        UILabel *lab=[[UILabel alloc]initWithFrame:CGRectMake(45, 0, WindowWidth-90, 40)];
        lab.text=title;
        lab.font=F(15);
        lab.textAlignment=NSTextAlignmentCenter;
        lab.textColor=[UIColor blackColor];
        [ self.whiteView addSubview:lab];
        UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(0, 40-0.5,WindowWidth, 0.5)];
        line.backgroundColor=C(@"d9d8d8");
        [ self.whiteView addSubview:line];
        
        UIButton*changeBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        changeBtn.frame=CGRectMake(WindowWidth-50, 0, 50, 40);
        [changeBtn setTitleColor:MainColor forState:UIControlStateNormal];
        [changeBtn setTitle:@"确定" forState:UIControlStateNormal];
        changeBtn.titleLabel.font=F(13);
        [changeBtn addTarget:self action:@selector(changeUser:) forControlEvents:UIControlEventTouchUpInside];
        [ self.whiteView addSubview:changeBtn];
    }
    
    return self;
}
- (void)changeUser:(UIButton*)sender
{
    self.hidden=YES;
    [UIView animateWithDuration:0.5 animations:^{
        self.whiteView.frame=CGRectMake(0,self.bounds.size.height , WindowWidth, self.originY);
    } completion:nil];
    if (self.submitBtnPress) {
        self.submitBtnPress();
    }
}
@end
